# This code is part of the MWP System
# Copyright (c) 2012 Benjamin Lubin (blubin@bu.com) 
# Published under and subject to the GPLv2 license available at http://www.gnu.org/licenses/gpl-2.0.html

'''
Created on Dec 14, 2012
@author: blubin
'''

from frontend.roleApplication import RoleApplication;
from frontend.form import Type;

class AdministratorApplication(RoleApplication):
    """ The Customer User Interface """

    def __init__(self):
        super(AdministratorApplication, self).__init__("PuppyService3", "Administrator");
        self.register_transition_step("ConfirmRequest", self.confirm_request_form_creator, name_fields=["sequence", "FirstName", "LastName", "Location", "DesiredTime"])
        self.register_sink_step("CollectPayment", self.collect_payment_form_creator, name_fields=["sequence", "FirstName", "LastName"])

    def confirm_request_form_creator(self, stepname, form):
        form.add_task_label(fields=["FirstName", "LastName", "Location", "DesiredTime"]) 
        form.add_field(Type.BOOLEAN, "TimeAvailable", labeltext="Confirm Appt?");
        form.add_field(Type.LONGSTRING, "Notes", labeltext="Notes")
    
    def collect_payment_form_creator(self, stepname, form):
        form.add_task_label(fields=["FirstName", "LastName"])
        form.add_field(Type.CURRENCY, "Amount", labeltext="Amount (in $)", initial=float(form.task.get_field("amount")))
        form.add_field(Type.CHOICE, "CreditCardType", choices=['Amex','Discover','Mastercard','Visa'], labeltext="Credit Card Type")
        form.add_field(Type.SHORTSTRING, "CreditCardNumber", labeltext="Credit Card Number")
        form.add_field(Type.DATE, "CreditCardExpiration", labeltext="Expiration Date")
        form.add_field(Type.SHORTSTRING, "CreditCardCCV", labeltext="Security Code")
    
if __name__ == '__main__':
    app = AdministratorApplication();
    app.MainLoop();